home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / amitcp / kern / amiga_time.h < prev    next >
C/C++ Source or Header  |  1993-08-12  |  3KB  |  113 lines

  1. #ifndef AMIGA_TIME_H
  2. #define AMIGA_TIME_H
  3. /*
  4.  * $Id: amiga_time.h,v 1.13 1993/06/04 11:16:15 jraja Exp $
  5.  * 
  6.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  7.  *                    Helsinki University of Technology, Finland.
  8.  *                    All rights reserved.
  9.  *
  10.  * $Log: amiga_time.h,v $
  11.  * Revision 1.13  1993/06/04  11:16:15  jraja
  12.  * Fixes for first public release.
  13.  *
  14.  * Revision 1.12  1993/05/17  01:02:04  ppessi
  15.  * Changed RCS version
  16.  *
  17.  * Revision 1.11  1993/03/13  17:13:02  ppessi
  18.  * Fixed bugs with variable initializations. Works with UDP.
  19.  *
  20.  * Revision 1.10  93/03/10  23:37:28  23:37:28  jraja (Jarno Tapio Rajahalme)
  21.  * Added comments.
  22.  * 
  23.  * Revision 1.9  93/03/10  23:08:17  23:08:17  jraja (Jarno Tapio Rajahalme)
  24.  * Changed timer_init() to return signal mask.
  25.  * 
  26.  * Revision 1.8  93/03/10  22:07:28  22:07:28  jraja (Jarno Tapio Rajahalme)
  27.  * Moved some functions to amiga_time.c.
  28.  * 
  29.  * Revision 1.7  93/03/05  12:31:42  12:31:42  jraja (Jarno Tapio Rajahalme)
  30.  * Changed TimerBase to struct Library also in GCC.
  31.  * 
  32.  * Revision 1.6  93/03/05  03:26:13  03:26:13  ppessi (Pekka Pessi)
  33.  * Compiles with SASC. Initial test version.
  34.  * 
  35.  * Revision 1.5  93/03/04  09:43:34  09:43:34  jraja (Jarno Tapio Rajahalme)
  36.  * Fixed includes.
  37.  * 
  38.  * Revision 1.4  93/03/03  15:43:40  15:43:40  jraja (Jarno Tapio Rajahalme)
  39.  * Moved timeval related definitions to sys/time.h.
  40.  * 
  41.  * Revision 1.3  93/02/24  12:54:10  12:54:10  jraja (Jarno Tapio Rajahalme)
  42.  * Changed uxkern to kern.
  43.  * 
  44.  * Revision 1.2  93/02/04  18:59:24  18:59:24  jraja (Jarno Tapio Rajahalme)
  45.  * Added prototypes and inlines for the Timer module (kern/amiga_time.c).
  46.  * 
  47.  * Revision 1.1  93/01/06  19:07:34  19:07:34  jraja (Jarno Tapio Rajahalme)
  48.  * Initial revision
  49.  */
  50.  
  51. #ifndef SYS_CDEFS_H
  52. #include <sys/cdefs.h>
  53. #endif
  54.  
  55. #ifndef AMIGA_INCLUDES_H
  56. #include <kern/amiga_includes.h>
  57. #endif
  58.  
  59. /*
  60.  * Globals defined in amiga_time.c
  61.  */
  62. extern struct Library     *TimerBase;
  63.  
  64. /*
  65.  * Define an extended timerequest to make implementing the UNIX kernel function
  66.  * timeout() easier.
  67.  */
  68.  
  69. typedef void (*TimerCallback_t)(void);
  70.  
  71. struct timeoutRequest {
  72.   struct timerequest timeout_request;    /* timer.device sees only this */
  73.   struct timeval     timeout_timeval;   /* timeout interval */
  74.   TimerCallback_t    timeout_function;  /* timeout function to be called */
  75. };
  76.  
  77.  
  78. /*
  79.  * Command field must be TR_ADDREQUEST before this is called!
  80.  * A request may be sent again ONLY AFTER PREVIOUS REQUEST HAS BEEN RETURNED!
  81.  */
  82. static inline void
  83. sendTimeoutRequest(struct timeoutRequest *tr)
  84. {
  85.   tr->timeout_request.tr_time = tr->timeout_timeval;
  86.   SendIO((struct IORequest *)&(tr->timeout_request));
  87. }
  88.  
  89. /*
  90.  * This MUST be called at splsoftclock()
  91.  */
  92. static inline void
  93. handleTimeoutRequest(struct timeoutRequest *tr)
  94. {
  95.   /*
  96.    * call the function
  97.    */
  98.   (*(tr->timeout_function))();
  99. }
  100.  
  101. /*
  102.  * prototypes for functions defined in kern/amiga_time.c
  103.  */
  104. ULONG timer_init(void);
  105. void timer_deinit(void);
  106. void timer_send(void);
  107. struct timeoutRequest * createTimeoutRequest(TimerCallback_t fun,
  108.                          ULONG seconds, ULONG micros);
  109. void deleteTimeoutRequest(struct timeoutRequest *tr);
  110. BOOL timer_poll(VOID);
  111.  
  112. #endif /* AMIGA_TIME_H */
  113.